<template>
	<view>
		<home v-if="PageCur=='home'"></home>
		<category v-if="PageCur=='category'"></category>
		<order v-if="PageCur=='order'"></order>
		<center v-if="PageCur=='center'"></center>
		<user v-if="PageCur=='user'"></user>
		<view :class="['cu-bar','tabbar','shadow','foot',theme.themeClass]">
			<view :class="[PageCur=='home'? theme.textClass:'text-gray','action']" @click="NavChange" data-cur="home">
				<view class="cuIcon-homefill"></view>
				<text>首页</text>
			</view>
			<view :class="[PageCur=='category'?theme.textClass:'text-gray','action']" @click="NavChange" data-cur="category">
				<view class="cuIcon-similar"></view>
				<text>分类</text>
			</view>
			<view :class="[PageCur=='center'?theme.textClass:'text-gray','action','add-action']" @click="NavChange" data-cur="center">
				<view :class="['cuIcon-cart',PageCur=='center'?theme.textClass:'']">
					<view class="cu-tag badge">9</view>
				</view>
				<text>购物车</text>
			</view>
			<view :class="[PageCur=='order'?theme.textClass:'text-gray','action']"  @click="NavChange" data-cur="order">
				<view class="cuIcon-text">
					<!-- <view class="cu-tag badge">99</view> -->
				</view>
				<text>订单</text>
			</view>
			<view :class="[PageCur=='user'?theme.textClass:'text-gray','action']"  @click="NavChange" data-cur="user">
				<view class="cuIcon-my">
					<!-- <view class="cu-tag badge"></view> -->
				</view>
				<text>我的</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex';
	export default {
		computed: mapState(['hasLogin', 'userinfo']),
		data() {
			return {
				theme: this.theme,
				PageCur: 'home'
			}
		},
		onLoad() {
			
			this.$api.WechatMaterial({name:'ces',age:76,content:null}).then(response=>{
				console.info("response",response);
			}).catch(error=>{
				console.info("error",error);
			})
		},
		methods: {
			...mapMutations(['setUserInfo','login']),
			NavChange: function(e) {
				this.PageCur = e.currentTarget.dataset.cur;
				console.info(this.hasLogin);
				this.login();
				this.$nextTick(function(){
					
					console.info(this.$store.state)
					console.info(this.hasLogin);
				})
			}
		}
	}
</script>

<style>

</style>
